import { get } from "@/api/request";

/**
 * 工作流控制器 / 工作流控制器获取已完成历史活动
 * @param {import("axios").AxiosRequestConfig} [config]
 * @returns {Promise<array<HistoricActivityInstance>>}
 * @author 方昊
 */
export function activitiQueryHistoricActivityInstance(config) {
  return get("/activiti/queryHistoricActivityInstance", config);
}

/**
 * 工作流控制器 / 工作流控制器获取已完成历史任务
 * @param {import("axios").AxiosRequestConfig} [config]
 * @returns {Promise<array<HistoricTaskInstance>>}
 * @author 方昊
 */
export function activitiQueryHistoricTaskInstanceByUserId(config) {
  return get("/activiti/queryHistoricTaskInstanceByUserId", config);
}

/**
 * 工作流控制器 / 工作流控制器查询模型定义列表
 * @param {import("axios").AxiosRequestConfig} [config]
 * @returns {Promise<array<Model>>}
 * @author 方昊
 */
export function activitiQueryModelDefinition(config) {
  return get("/activiti/queryModelDefinition", config);
}

/**
 * 工作流控制器 / 工作流控制器查询流程定义列表
 * @param {import("axios").AxiosRequestConfig} [config]
 * @returns {Promise<array<ProcessDefinition>>}
 * @author 方昊
 */
export function activitiQueryProcessDefinition(config) {
  return get("/activiti/queryProcessDefinition", config);
}

/**
 * 工作流控制器 / 工作流控制器获取当前处理人所有任务列表
 * @param {import("axios").AxiosRequestConfig} [config]
 * @returns {Promise<array<Task>>}
 * @author 方昊
 */
export function activitiQueryTaskInstance(config) {
  return get("/activiti/queryTaskInstance", config);
}

/**
 * 工作流控制器 / 工作流控制器查看工作流图片
 * @param {object} params
 * @param {string} params.pId 流程实例ID
 * @param {import("axios").AxiosRequestConfig} [config]
 * @returns {Promise}
 * @author 方昊
 */
export function activitiViewProcessImgPId(params, config) {
  get({ url: "/activiti/viewProcessImg", pathParams: params, config });
}

/**
 * 工作流控制器 / 工作流控制器获取审批历史
 * @param {object} params
 * @param {number} params.businessId 业务ID
 * @param {string} params.workflowType 工作流类型
 * @param {import("axios").AxiosRequestConfig} [config]
 * @returns {Promise<array<HistoryVO>>}
 * @author 方昊
 */
export function systemWorkflowHistory(params, config) {
  return get("/system/workflow/history", params, config);
}

/**
 * @typedef {object} CommentVO 备注信息
 * @property {string} fullMessage 备注信息
 * @property {string} id ID
 * @property {string} taskId 任务ID
 * @property {string} time 时间
 * @property {string} type 备注类型
 * @property {string} userId 用户ID
 * @description 备注信息
 */

/**
 * @typedef {object} HistoricActivityInstance
 * @property {string} activityId
 * @property {string} activityName
 * @property {string} activityType
 * @property {string} assignee
 * @property {string} calledProcessInstanceId
 * @property {string} deleteReason
 * @property {number} durationInMillis
 * @property {string} endTime
 * @property {string} executionId
 * @property {string} id
 * @property {string} processDefinitionId
 * @property {string} processInstanceId
 * @property {string} startTime
 * @property {string} taskId
 * @property {string} tenantId
 * @property {string} time
 */

/**
 * @typedef {object} HistoricTaskInstance
 * @property {string} assignee
 * @property {string} category
 * @property {string} claimTime
 * @property {string} createTime
 * @property {string} deleteReason
 * @property {string} description
 * @property {string} dueDate
 * @property {number} durationInMillis
 * @property {string} endTime
 * @property {string} executionId
 * @property {string} formKey
 * @property {string} id
 * @property {string} name
 * @property {string} owner
 * @property {string} parentTaskId
 * @property {number} priority
 * @property {string} processDefinitionId
 * @property {string} processInstanceId
 * @property {object} processVariables
 * @property {string} startTime
 * @property {string} taskDefinitionKey
 * @property {object} taskLocalVariables
 * @property {string} tenantId
 * @property {string} time
 * @property {number} workTimeInMillis
 */

/**
 * @typedef {object} HistoryVO 工作流历史页面展示实体
 * @property {string} assigneeName 任务代理人姓名
 * @property {string} assigneeOrg 任务代理人组织
 * @property {string} assigneeUsername 任务代理人用户名
 * @property {array<CommentVO>} comments 备注
 * @property {string} description 描述
 * @property {boolean} finished
 * @property {string} name 任务名称
 * @property {string} time 开始时间
 * @description 工作流历史页面展示实体
 */

/**
 * @typedef {object} Model
 * @property {string} category
 * @property {string} createTime
 * @property {string} deploymentId
 * @property {string} id
 * @property {string} key
 * @property {string} lastUpdateTime
 * @property {string} metaInfo
 * @property {string} name
 * @property {string} tenantId
 * @property {number} version
 */

/**
 * @typedef {object} ProcessDefinition
 * @property {string} category
 * @property {string} deploymentId
 * @property {string} description
 * @property {string} diagramResourceName
 * @property {string} engineVersion
 * @property {string} id
 * @property {string} key
 * @property {string} name
 * @property {string} resourceName
 * @property {boolean} suspended
 * @property {string} tenantId
 * @property {number} version
 */

/**
 * @typedef {object} Task
 * @property {string} assignee
 * @property {string} category
 * @property {string} claimTime
 * @property {string} createTime
 * @property {string} delegationState 可选值: PENDING, RESOLVED
 * @property {string} description
 * @property {string} dueDate
 * @property {string} executionId
 * @property {string} formKey
 * @property {string} id
 * @property {string} name
 * @property {string} owner
 * @property {string} parentTaskId
 * @property {number} priority
 * @property {string} processDefinitionId
 * @property {string} processInstanceId
 * @property {object} processVariables
 * @property {boolean} suspended
 * @property {string} taskDefinitionKey
 * @property {object} taskLocalVariables
 * @property {string} tenantId
 */
